const mongoose = require("mongoose");
// mongoose.connect("mongodb://localhost/test",{useMongoClient:true});
mongoose.connect("mongodb://localhost:27017/test", { useNewUrlParser: true });
mongoose.Promise = Promise;

const Album = mongoose.model("Album",{
  albumName:String,
  createTime:Date,
  active:Boolean
});

async function run() {
  var defaultAlbum = await Album.findOne({albumName:"default"});
  if(!defaultAlbum) {
    var album = new Album({
      albumName:"default",
      createTime:new Date(),
      active:true
    });
    await album.save();
  }
}
run();
module.exports = Album;
